<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>

<section id="user-init-section">
	<div class="row-fluid">
		<div class="span6">
			<div class="page-header">
				<h3>Sign up</h3>
			</div>
		</div>
		<div class="span18">
			<form:form action="user/signup" method="post" id="signupform"
				class="form-horizontal" modelAttribute="user">
				<fieldset>
					<div class="control-group">
						<label class="control-label" for="email">Email</label>
						<div class="controls">
							<form:input path="email" class="input-xlarge"/>
							<form:errors path="email" />
						</div>
					</div>
					<div class="control-group">
						<label class="control-label" for="password">Password</label>
						<div class="controls">
							<form:password path="password" class="input-xlarge"/>
							<form:errors path="password" />
						</div>
					</div>
					<div class="control-group">
						<label class="control-label" for="password2">Repeated Password</label>
						<div class="controls">
							<input type="password" class="input-xlarge" id="password2" />
						</div>
					</div>
					<div class="form-actions">
						<button type="submit" class="ks-button ks-button-primary">Sign
							up</button>
					</div>
				</fieldset>
			</form:form>
		</div>
	</div>
</section>

<script>
	KISSY.ready(function(S) {
		S.use("validation", function(S, Validation) {
			var check = new Validation('#signupform', {
				style : "text",
				event : 'blur'
			});

			check.add("#email", {
				email : true,
				required : true,
				remote : [ "user/checkEmail" ],
				minLength : [ 6, true, "不能少于6个字符" ]
			});

			check.add("#password", {
				required : true,
				length : [ 6, 12, true ]
			});

			check.add("#password2",{
				equalTo:['#password','两次密码不一致']
			});
			
			KISSY.Event.on('#signupform', "submit", function() {
				return check.isValid();
			});

		});
	});
</script>